home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Sample Code / DTS QT Utilities.Aug-95 / Projects & Test Apps / MovieShell / Mac Framework / MacApplication.c < prev    next >
Encoding:
Text File  |  1995-03-31  |  3.8 KB  |  169 lines  |  [TEXT/MPCC]

  1. /*
  2.     File:        MacApplication.c
  3.  
  4.     Contains:    Functions that could be overridden in a specific application.
  5.  
  6.     Written by:    DTS
  7.  
  8.     Copyright:    © 1994-1995 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.        <1>         12/21/94    khs        first file
  13.        
  14. */
  15.  
  16.  
  17. // INCLUDES
  18. #include "MacApplication.h"
  19. #include "MacFramework.h"
  20. #include "AppConfiguration.h"
  21. #include "DTSQTUtilities.h"
  22.  
  23. // Header file for the specific test functions.
  24. #include "TestFunctions.h"
  25.  
  26. // GLOBALS
  27. long gMaxMilliSecToUse = kMaxMilliSecToUse;        
  28.  
  29.  
  30. // FUNCTIONS
  31. // ______________________________________________________________________
  32. void DoIdle(WindowRef theWindow)
  33. {
  34.     GrafPtr                 aSavedPort;
  35.     WindowObject         aWindowObject;
  36.     MovieController     mc = NULL;
  37.     
  38.     GetPort(&aSavedPort);
  39.     SetPort(theWindow);
  40.     
  41.     if( (aWindowObject = (WindowObject)GetWRefCon(theWindow) ) != NULL)
  42.     {
  43.         if( (mc = (**aWindowObject).controller) != NULL)
  44.             MoviesTask(MCGetMovie(mc), gMaxMilliSecToUse);    
  45.     }
  46.  
  47. // @@@INSERT ANY IDLE BASED FUNCTIONALITY HERE
  48.  
  49.     SetPort(aSavedPort);
  50. }
  51.  
  52.  
  53. // ______________________________________________________________________
  54. void DoUpdateWindow(WindowRef theWindow, Rect *theRefrehArea)
  55. {
  56.     GrafPtr aSavedPort;
  57.     
  58.     GetPort(&aSavedPort);
  59.     SetPort(theWindow);
  60.     
  61.     BeginUpdate(theWindow);
  62.  
  63. // @@@INSERT WINDOW SPECIFIC DRAWING FUNCTIONALITY HERE
  64.  
  65.     EndUpdate(theWindow);
  66.     SetPort(aSavedPort);
  67. }
  68.  
  69.  
  70. // ______________________________________________________________________
  71. void HandleContentClick(WindowRef theWindow, EventRecord *theEvent)
  72. {
  73.     GrafPtr aSavedPort;
  74.     
  75.     GetPort(&aSavedPort);
  76.     SetPort(theWindow);
  77.  
  78. // @@@INSERT APPLICATION SPECIFIC CONTENT CLICKING FUNCTIONALITY HERE
  79.  
  80.     SetPort(aSavedPort);
  81. }
  82.  
  83.  
  84. // ______________________________________________________________________
  85. WindowRef CreateMovieWindow(Rect *theRect, Str255 theTitle)
  86. {
  87.     WindowRef aWindow;
  88.  
  89. // MODIFY IF NEEDED THE WAY TO CREATE NEW WINDOWS    
  90.     aWindow = NewCWindow(NULL, theRect, theTitle, false, noGrowDocProc, (WindowPtr) - 1L, true, 0);
  91.     return aWindow;
  92. }
  93.  
  94. // ______________________________________________________________________
  95. void HandleApplicationMenu(short theMenuID, short theMenuItem)
  96. {
  97.     //  HANDLE ANY ADDITIONAL MENU ENTRIES HERE
  98.     switch(theMenuID)
  99.     {
  100.         case mTesting:
  101.             switch(theMenuItem)
  102.             {
  103.                 case iTest1:
  104.                 {
  105.                 // @@@INSERT YOUR TEST FUNCTION 1 HERE
  106.                     ResizeTheMovieWindow(kNormalMovieSize);
  107.                     break;
  108.                 }
  109.                 
  110.                 case iTest2:
  111.                 {
  112.                 // @@@INSERT YOUR TEST FUNCTION 2 HERE
  113.                     ResizeTheMovieWindow(kHalfMovieSize);
  114.                     break;
  115.                 }
  116.                 
  117.                 case iTest3:
  118.                 {
  119.                 // @@@INSERT YOUR TEST FUNCTION 3 HERE
  120.                     ResizeTheMovieWindow(kDoubleMovieSize);
  121.                     break;
  122.                 }
  123.             }
  124.             break;
  125.     }
  126. }
  127.  
  128.  
  129. // ______________________________________________________________________
  130. void    AdjustApplicationMenus(void)
  131. {
  132.     WindowRef             aWindow = NULL;
  133.     MovieController     mc = NULL;
  134.     
  135.     mc = GetMCFromFrontWindow();
  136.     if(mc != NULL)                                // we do have windows with movie controllers = movie windows
  137.     // @@@ADJUST YOUR MENUS HERE
  138.     {
  139.         EnableItem(GetMHandle(mTesting), iTest1);
  140.         EnableItem(GetMHandle(mTesting), iTest2);
  141.         EnableItem(GetMHandle(mTesting), iTest3);
  142.     }
  143.     else
  144.     {
  145.         DisableItem(GetMHandle(mTesting), iTest1);
  146.         DisableItem(GetMHandle(mTesting), iTest2);
  147.         DisableItem(GetMHandle(mTesting), iTest3);
  148.     }
  149. }
  150.  
  151.  
  152. // ______________________________________________________________________
  153. void AddControllerFunctionality(MovieController mc)
  154. {
  155.     long controllerFlags;
  156.  
  157. // @@@MOVIE CONTROLLER FUNCTIONALITY
  158. // Specify here the functionality you want to have added to the movie controller.
  159.  
  160. // CLUT Table use    
  161.     MCDoAction(mc, mcActionGetFlags, &controllerFlags);
  162.     MCDoAction(mc, mcActionSetFlags, (void *) (controllerFlags | mcFlagsUseWindowPalette));
  163.  
  164. // Enable keyboard event handling    
  165.     MCDoAction(mc, mcActionSetKeysEnabled, (void *) true);
  166.     
  167. // Enable Drag Support (assume we have System 7.5 for the time being)
  168.     MCDoAction(mc, mcActionSetDragEnabled, (void *) true);
  169. }